<?php

namespace app\index\service;

use app\index\model\UM as UM;
use ShidianUtil\Exception\DataNotExistException;
use app\index\dao\LawsuitOptionalDao;
use app\common\model\LawsuitOptional;
use think\Collection;

/**
 * Class OptionalService
 * @package app\index\service
 */
class OptionalService
{
    // dao
    private LawsuitOptionalDao $lawsuitOptionalDao;

    public function __construct(LawsuitOptionalDao $lawsuitOptionalDao)
    {
        $this->lawsuitOptionalDao = $lawsuitOptionalDao;
    }

    /**
     * 可选题列表
     * @param UM|null $user
     * @param $categoryId
     * @return Collection
     */
    public function index(?UM $user, $categoryId): Collection
    {
        return $this->lawsuitOptionalDao
            ->select($categoryId)
            ->each(function (LawsuitOptional $optional) {
                $optional['result'] = null;
            });
    }

}
